const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");

const { VueLoaderPlugin } = require("vue-loader")

module.exports = {
  mode: "development",
  entry: path.resolve(__dirname, "./src/main.ts"),
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "dist")
  },
  resolve: {
    extensions: [".ts", ".tsx", ".js", ".vue"]
  },
  module: {
    rules: [
      {
        test: /\.(ts|js)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ['@babel/preset-env', [
              "@babel/preset-typescript", {
                "allExtensions": true
              }
            ]]
          }
        },
        include: path.resolve(__dirname, "src")
      },
      // {
      //   test: /\.ts$/,
      //   exclude: /node_modules/,
      //   use: {
      //     loader: "ts-loader",
      //     options: {
      //       configFile: path.resolve(__dirname, "./tsconfig.json"),
      //       appendTsSuffixTo: [/\.vue$/]
      //     }
      //   },
      //   include: path.resolve(__dirname, "src")
      // },

      {
        test: /\.vue$/,
        use: ["vue-loader"]
      },
      {
        test: /\.(svg|otf|ttf|woff|woff2|eot|gif|png)$/,
        use: "url-loader"
      },
      {
        test: /\.(scss|css)$/,
        use: [
          "style-loader",
          "css-loader",
          "sass-loader"
        ]
      }
    ]
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "./public/index.html")
    })
  ]
}